/*
 * SetLineStyleAction.java
 * 
 * Created by demory on Feb 28, 2010, 11:38:27 PM
 * 
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.fpdev.apps.cart.actions;

import org.fpdev.apps.cart.Cartographer;
import org.fpdev.apps.cart.Editor;
import org.fpdev.apps.cart.network.Line;
import org.fpdev.apps.cart.network.LineStyle;

/**
 *
 * @author demory
 */
public class SetLineStyleAction extends EditorBasedAction {

  private Line line_;
  private LineStyle oldStyle_, newStyle_;

  public SetLineStyleAction(Editor ed, Line line, LineStyle style) {
    super(ed);
    line_ = line;
    newStyle_ = style;
    System.out.println("line = "+line);
    oldStyle_ = line.getStyle();
  }

  public boolean doAction(Cartographer cart) {
    line_.setStyle(newStyle_);
    cart.getGUI().getControlFrameManager().getLinesFrame().updateRow(line_);
    return true;
  }

  public boolean undoAction(Cartographer cart) {
    line_.setStyle(oldStyle_);
    cart.getGUI().getControlFrameManager().getLinesFrame().updateRow(line_);
    return true;
  }

  public String getName() {
    return "Change Line Style";
  }

}
